package vn.gq.udv.comic.fragment;

import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import vn.gq.udv.comic.Configuration;
import vn.gq.udv.comic.R;
import vn.gq.udv.tab.BaseFragment;
import vn.gq.udv.utils.UrlHandler;

public class AppStoreFragment extends BaseFragment {

	private WebView mWebView; 
	private ProgressBar mProgressBar;
	
	
	public static AppStoreFragment newInstance() {
		AppStoreFragment f = new AppStoreFragment();
		
		return f;
	}
	
	@Override
	public int getContainerId() {
		return 0;
	}

	@Override
	public int getLayoutId() {
		return R.layout.webview_layout;
	}

	@Override
	public void createView() {
		mWebView = (WebView) mLayout.findViewById(R.id.webview);
		mProgressBar = (ProgressBar) mLayout.findViewById(R.id.loading);
		mWebView.setWebViewClient(new WebViewClient() {
			
			@Override
			public void onPageFinished(WebView view, String url) {
				mProgressBar.setVisibility(View.GONE);
				mWebView.setVisibility(View.VISIBLE);
				super.onPageFinished(view, url);
			}

			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				return new UrlHandler(getActivity()).appURLHandler(view, url);
			}
			
		});
		mWebView.setWebChromeClient(new WebChromeClient() {
			
		});
		mWebView.loadUrl(Configuration.URL_LIST_APP);
	}
	
}
